﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebApp.BLL.Base;
using WebApp.DAL;
using WebApp.Models;

namespace WebApp.BLL.Manage
{
    public partial class S_user_roleService : BaseService<S_user_role>
    {
        #region 构造

        public S_user_roleService() : base(new S_user_roleRepository()) { }

        #endregion

        #region SelectByUserid

        public List<S_user_role> SelectByUserid(int userid)
        {
            return this.CurrentRepository.Entities.Where(p => p.User_id == userid).ToList();
        }

        #endregion

        #region GetByUseridAndRoleid

        public S_user_role GetByUseridAndRoleid(int userid, string roleid)
        {
            return this.CurrentRepository.Entities.FirstOrDefault(p => p.User_id == userid && p.Roleid == roleid);
        }

        #endregion

        #region GetUserIdsByRoleid

        public List<int> GetUserIdsByRoleid(string roleid)
        {
            return this.CurrentRepository.Entities.Where(p => p.Roleid == roleid).Select(p => p.User_id.Value).ToList();
        }

        #endregion

    }
}
